home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8342 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  66 lines

  1. Path: pacifica.access.ch!usenet
  2. From: tombeck@usemail.com (Thomas Beck)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Please please help a newbie!
  5. Date: 16 Feb 1996 23:36:24 GMT
  6. Organization: Internet Access AG, Zuerich, Switzerland
  7. Message-ID: <4g34do$mg0@pacifica.access.ch>
  8. References: <4ftoe8$5a2@pacifica.access.ch>
  9. NNTP-Posting-Host: gatezh2-16.access.ch
  10. X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
  11.  
  12. In message <3124EEF1.3234@bnr.ca> - Mike Alexander <mikealex@bnr.ca> writes:
  13.  
  14. >> ----------- example 2: -------------
  15. >> struct abc {
  16. >>   int i;
  17. >>   char a;
  18. >>   void f1() {
  19. >>   };
  20. >> };
  21. >> 
  22. >> main() {
  23. >> }
  24. >> ---------------------------------------------
  25. >
  26. >I'm not a 100% sure what you are trying to do here, but I think
  27. >you are trying to define a class with f1() being an inline function.
  28. >If I'm right, then you should be defining abc to be a class, not a
  29. >struct. You're code would look like:
  30. >
  31. >    class abc {
  32. >      int i;
  33. >      char a;
  34. >      void f1() {}    // <-- note, the ; after this closing
  35. >            //     closing brace is optional
  36. >    };
  37. >
  38.  
  39. Hm, the way I learnt it, struct and class are equal except for the fact that 
  40. the default state in a class is private whereas it is public in a struct. 
  41. So...
  42.  
  43. class abc {        should be equal to        struct abc {
  44.     private:                            private:
  45.     stuff...                            stuff....
  46.     public:                            public:
  47.     stuff...                            stuff....
  48. }                            }
  49.  
  50. Am I wrong?
  51.  
  52. >Some of this may be a little more than you have gotten too in your
  53. >book though (such as constructors, destructors, and automatic
  54. >initializers).
  55.  
  56. I've learned it today :-)
  57.  
  58. Thomas Beck, tombeck@usemail.com
  59.  
  60. =================================================================
  61. Summer's day, as she passed away. Birds were singing in the
  62. summer sky; then came the rain, and once again, a tear fell
  63. from her mother's eye...
  64. =================================================================
  65.  
  66.